
#include "map.h"
#include "block.h"

using namespace Blox;


Map::Map()
	: m_pRoot(NULL)
{

}

Map::~Map()
{
	if( m_pRoot )
	{
		delete m_pRoot;
	}
}

void Map::Init( Bounds const & rBounds )
{
	delete m_pRoot;
	m_pRoot = new Block( );
	m_pRoot->Init( NULL, rBounds );
}

void Blox::Map::Draw() const
{
	if( m_pRoot )
	{
		m_pRoot->DrawRecursive();
	}
}

Blox::Block * Blox::Map::GetSmallestEncompassingBlock( AABB const & rObject ) const
{
	Bounds bounds( rObject );

	Block * pBlock = m_pRoot->GetEncompassingBlock(bounds);

	return pBlock;
}
